<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  <input type="text" class="username">
  <input type="text" class="password">
  <input type="button" class="btn" value="登录">
</body>
<script>

  $(".btn").onclick = function(){
    const xhr = new XMLHttpRequest();
    xhr.open("get", "http://localhost:3000/login?username="+$(".username").value+"&password="+$(".password").value);
    xhr.onload = function(){
      res = JSON.parse(xhr.responseText);
      console.log(res);
      localStorage.setItem("token", res.token);
    }
    xhr.send();
  }

  function $(sel){
    return document.querySelector(sel)
  }
</script>
</html>